﻿@model PlmPersonLeaveViewModel
@{
    Layout = null;
    ViewBag.Title = "监理人员请假管理——列表";
}
@using (Html.BeginForm("SplitPage", "PlmPersonLeave", null, FormMethod.Post, new { id = "pagerForm", onsubmit = "return navTabSearch(this);" }))
{
    <input type="hidden" name="pageNum" value="1" />
    <input type="hidden" name="numPerPage" value="@(ViewBag.numPerPage)" />
    <ul class="searchBar" style="border-top:1px solid #b8d0d6;">
        <li><span>申请日期：</span>
            <input type="text" name="time" value="@(ViewBag.time)" class="date"/>
        </li>
        <li><span>标段：</span>
            <input type="text" name="section" value="@(ViewBag.section)" />
        </li>
        <li><span>请假/顶岗人：</span>
            <input type="text" name="name" value="@(ViewBag.name)" />
        </li>
        <li>
            <button type="submit" class="btn btn-success btn-xs">
                搜索</button>
        </li>
    </ul>
}
<div class="panelBar" style="border-top:none;">
    <ul class="toolBar">
        <li>
            @Html.PermissionButton("PersonnelLog.PlmPersonLeave.Create", "PersonnelLog_PlmPersonLeave_Add",
                    Url.Action("PersonLeaveAdd", "PlmPersonLeave"),
                    "添加",
                    new Dictionary<string, object>
                    {
                        {"class","add"},{"rel","rygl_qjgl_add"} ,{"mask","true"},{"target","dialog"},{"width","420"},{"height","420"}
                    })
        </li>
        <li>
            @Html.PermissionButton("PersonnelLog.PlmPersonLeave.Delete", "PersonnelLog_PlmPersonLeave_Delete",
                    Url.Action("PersonLeaveMultiDelete", "PlmPersonLeave", new { id = "{tr_id}" }),
                    "删除",
                    new Dictionary<string, object>
                    {
                        {"class","delete"},{"mask","true"} ,{"title","确定要删除该条记录吗？"},{"target","ajaxTodo"}
                    })
        </li>
        <li>
            @Html.PermissionButton("PersonnelLog.PlmPersonLeave.Edit", "PersonnelLog_PlmPersonLeave_Edit",
                    Url.Action("PersonLeaveEdit", "PlmPersonLeave", new { id = "{tr_id}" }),
                    "修改",
                    new Dictionary<string, object>
                    {
                        {"class","edit"},{"rel","rygl_qjgl_edit"} ,{"warn","请选择一条信息！"},{"target","dialog"},{"mask","true"},{"width","420"},{"height","420"}
                    })
        </li>
        <li>
            @Html.PermissionButton("PersonnelLog.PlmPersonLeave.Detail", "PersonnelLog_PlmPersonLeave_Detail",
                    Url.Action("PersonLeaveDetail", "PlmPersonLeave", new { id = "{tr_id}" }),
                    "查看",
                    new Dictionary<string, object>
                    {
                        {"class","detail"},{"rel","rygl_qjgl_detail"} ,{"warn","请选择一条信息！"},{"target","dialog"},{"mask","true"},{"width","480"},{"height","320"}
                    })
        </li>
         <li class="line">line</li>
        <li>
            @Html.PermissionButton("PersonnelLog.PlmPersonLeave.Report", "PersonnelLog_PlmPersonLeave_Report",
                    Url.Action("PersonLeaveAudit", "PlmPersonLeave", new { id = "{tr_id}" }),
                    "上报",
                    new Dictionary<string, object>
                    {
                        {"class","report"},{"rel","rygl_qjgl_report"} ,{"warn","请选择一条信息！"},{"target","dialog"},{"mask","true"},{"width","400"},{"height","320"}
                    })
        </li>
    </ul>
</div>
<table class="table" width="100%" layouth="122" nowraptd="false">
    <thead>
        <tr>
            <th align="center" width="30">
                序号
            </th>
            <th align="center" width="80">
                申请日期
            </th>
            <th align="center" width="80">
                标段
            </th>
            <th align="center" width="100">
                请假人
            </th>
            <th align="center" width="110">
                顶岗人
            </th>
            <th align="center" width="110">
                请假起止时间
            </th>
            <th align="center" width="80">
                审批状态
            </th>
        </tr>
    </thead>
    <tbody>
        @{ int num = (ViewBag.pageNum - 1) * ViewBag.numPerPage;
           string state = "";}
        @foreach (var item in Model.PersonleaveList)
        {
            num += 1;
            switch (item.Pl_State)
            {
                case 0:
                    state = "草稿";
                    break;
                case 1:
                    state = "主任审批";
                    break;
                case 2:
                    state = "总监审批";
                    break;
                case 3:
                    state = "部长审批";
                    break;
                case 4:
                    state = "领导审批";
                    break;
                case 5:
                    state = "审批通过";
                    break;
                case 6:
                    state = "审批不通过";
                    break;
                default:
                    break;
            }
                   
                
            <tr target="tr_id" rel="@item.Pl_ID" data-dailycheck="true" data-state="@item.Pl_State" data-sole="PersonnelLog_PlmPersonLeave">
                <td align="center">@num
                </td>
                <td align="center">@item.Pl_Time.ToString("yyyy-MM-dd")
                </td>
                <td align="center">@item.Pl_Section
                </td>
                <td align="center">
                    <a href="@Url.Action("PersonLeaveDetail", "PlmPersonLeave", new { id = item.Pl_ID })" title="查看" rel="trygl_qjgl_detail" target="dialog" mask="true" width="480" height="320">@item.Pl_PersonName</a>
                </td>
                <td align="center">@item.Pl_CoverMan
                </td>
                <td align="center">@item.Pl_StartDate.ToString("yyyy-MM-dd")~@item.Pl_EndDate.ToString("yyyy-MM-dd")
                </td>
                <td>
                    @(state)
                </td>
            </tr>
        }
    </tbody>
</table>
<div class="panelBar" style="border-bottom:none;">
    <div class="pages" style="float: right">
        <span>显示</span>
        <select class="comsplitpage" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
            <option value="10" @(ViewBag.numPerPage == 10 ? "selected='selected'" : "")>10</option>
                <option value="20" @(ViewBag.numPerPage == 20 ? "selected='selected'" : "")>20</option>
                <option value="50" @(ViewBag.numPerPage == 50 ? "selected='selected'" : "")>50</option>
        </select>
        <span>条，共@(ViewBag.pagenumshown)页,@(ViewBag.totalcount)条</span>
    </div>
    <div class="pagination" style="margin:0px;float:left; margin-left:35%" targettype="navTab" totalcount="@(ViewBag.totalcount)" numperpage="@(ViewBag.numPerPage)" pagenumshown="10" currentpage="@(ViewBag.pageNum)">
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("select[name='numPerPage']:eq(0)").val(@(ViewBag.numPerPage));
    });

    $.jTableTool.clickRowAction(function ($row) {
        if ($row) {
            if($row.data("sole")!="PersonnelLog_PlmPersonLeave")
            return;
            var isDailyCheck = $row.data("dailycheck");
            var state = $row.data("state");
            if (isDailyCheck) {
                //审批状态(0=待审批，1=驻地/检测主任审批，2=总监审批，3=质监部部长批示，4=主管领导批示，5=审批通过，6=审批不通过)
                if (state != 0) {
                    //已经下发了
                    $("#PersonnelLog_PlmPersonLeave_Delete").hide();
                    $("#PersonnelLog_PlmPersonLeave_Edit").hide();
                    $("#PersonnelLog_PlmPersonLeave_Report").hide();
                } else {
                    $("#PersonnelLog_PlmPersonLeave_Delete").show();
                    $("#PersonnelLog_PlmPersonLeave_Edit").show();
                    $("#PersonnelLog_PlmPersonLeave_Report").show();
                }
                
            }
        }
    });
</script>
